"use strict";
cc._RF.push(module, 'cdcbbcYj61HG6ECBc5SKnmm', 'role_skill');
// scripts/role_skill.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("GlobalParams"),
    i = e("d_monster_item"),
    r = e("monster_node_info"),
    s = e("node_team"),
    l = e("role_node"),
    _ = e("team_node_info"),
    c = e("tower_node_info"),
    d = cc._decorator,
    h = d.ccclass,
    u = (d.property, function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.role_common_skill = null, t.role_skill_one = null, t.role_skill_two = null, t.role_skill_three = null, t.role_info = null, t.ack_range = 0, t.role_rigidbody = null, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    this.role_info = this.node.getComponent(l["default"]), this.role_rigidbody = this.node.getComponent(cc.RigidBody), this.role_rigidbody.active = !1;

    for (var e = 0, t = this.node.getComponentsInChildren(cc.BoxCollider); e < t.length; e++) {
      var o = t[e];
      1 == o.tag && (this.role_common_skill = o, o.enabled = !1, this.ack_range = 1.5 * Math.abs(o.offset.x)), 2 == o.tag && (this.role_skill_one = o, o.enabled = !1), 3 == o.tag && (this.role_skill_two = o, o.enabled = !1), 4 == o.tag && (this.role_skill_three = o, o.enabled = !1);
    }
  }, t.prototype.roleCommonSkill = function (e, t) {
    this.role_common_skill.enabled = e && "attack" == t, this.role_skill_one.enabled = e && "attack_skill_1" == t, this.role_skill_two.enabled = e && "attack_skill_2" == t, this.role_skill_three.enabled = e && "attack_skill_3" == t;
  }, t.prototype.onCollisionEnter = function (e, t) {
    var o = e.node,
        a = o.group;

    if (o.isValid) {
      if ((1 == t.tag || 2 == t.tag || 3 == t.tag || 4 == t.tag) && 0 == e.tag) if ("soldier" == a) {
        var d = o.getComponent(_["default"]);
        d.team_info != this.node.getComponent(s["default"]).getTeamInfo() && d.soldierBeHit(this.role_info.getRoleSkillAttack(t.tag), this.role_info.match_game_index);
      } else if ("role" == a || "tower" == a) {
        if (o.getComponent(s["default"]).getTeamInfo() != this.node.getComponent(s["default"]).getTeamInfo()) if ("role" == a) this.role_info.setForSpeed(o.getComponent(l["default"]).getEquipForSpeed()), o.getComponent(l["default"]).roleBeHit(this.role_info.getRoleSkillAttack(t.tag), this.role_info.match_game_index);else if ("tower" == a) {
          var h = this.role_info.getRoleSkillAttack(t.tag);
          1 != t.tag && (h *= 0.5), o.getComponent(c["default"]).towerBeHit(h, this.role_info.match_game_index);
        }
      } else "monster" == a && (2 != n.GlobalParams.MultiModeIndex ? o.getComponent(r["default"]).attackMonster(this.role_info.getRoleSkillAttack(t.tag), this.role_info.match_game_index, this.node) : o.getComponent(i["default"]).attackMonster(this.role_info.getRoleSkillAttack(t.tag)));
      99 == t.tag && "map" == a && (this.role_rigidbody.active = !0, this.role_rigidbody.syncPosition(!0), this.role_info.heroFlashOver(), this.node.stopAllActions());
    }
  }, t.prototype.onCollisionExit = function (e, t) {
    var o = e.node,
        a = o.group;
    o.isValid && 99 == t.tag && "map" == a && 99 == e.tag && (this.role_rigidbody.active = !1);
  }, t.prototype.onBeginContact = function (e, t, o) {
    var a = o.node.group;
    "role" != a && "soldier" != a || (e.disabled = !0), "map" == a && (this.role_info.is_flash = !1);
  }, t.prototype.onEndContact = function (e, t, o) {
    "map" == o.node.group && (this.role_info.is_flash = !0);
  }, oo([h], t);
}(a["default"]));

o["default"] = u;

cc._RF.pop();